cmake_minimum_required(VERSION 3.21.12)
project(sRpc)
# 设置c++ 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# 设置头文件搜索路径
include_directories(${PROJECT_SOURCE_DIR}/include /usr/include /usr/local/include)
# 动态链接库搜索路径
link_directories(/usr/lib /usr/local/lib)
# 查找包
find_package(Protobuf REQUIRED)

file(GLOB SRC ${PROJECT_SOURCE_DIR}/src/*.cc)

set(LIBS
    protobuf
    pthread
    zookeeper_mt
    muduo_net
    muduo_base
    glog
)

add_library(sRpc SHARED ${SRC})
link_libraries(${LIBS})

file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/lib/)

add_custom_command(
    TARGET sRpc
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:sRpc> ${CMAKE_SOURCE_DIR}/lib/
    COMMENT "拷贝文件到lib路径下"
    VERBATIM
)

add_subdirectory(example)